package com.qinggeng.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qinggeng.framework.aspectj.lang.annotation.Log;
import com.qinggeng.framework.aspectj.lang.enums.BusinessType;
import com.qinggeng.project.system.domain.GoodsDefaultEvaluate;
import com.qinggeng.project.system.service.IGoodsDefaultEvaluateService;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.common.utils.poi.ExcelUtil;
import com.qinggeng.framework.web.page.TableDataInfo;
/**
 * 商品默认评价Controller
 * 
 * @author smallfish
 * @date 2021-01-05
 */
@RestController
@RequestMapping("/system/evaluate")
public class GoodsDefaultEvaluateController extends BaseController
{
    @Autowired
    private IGoodsDefaultEvaluateService goodsDefaultEvaluateService;

    /**
     * 查询商品默认评价列表
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsDefaultEvaluate goodsDefaultEvaluate)
    {
        startPage();
        List<GoodsDefaultEvaluate> list = goodsDefaultEvaluateService.selectGoodsDefaultEvaluateList(goodsDefaultEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出商品默认评价列表
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:export')")
    @Log(title = "商品默认评价", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GoodsDefaultEvaluate goodsDefaultEvaluate)
    {
        List<GoodsDefaultEvaluate> list = goodsDefaultEvaluateService.selectGoodsDefaultEvaluateList(goodsDefaultEvaluate);
        ExcelUtil<GoodsDefaultEvaluate> util = new ExcelUtil<GoodsDefaultEvaluate>(GoodsDefaultEvaluate.class);
        return util.exportExcel(list, "evaluate");
    }

    /**
     * 获取商品默认评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(goodsDefaultEvaluateService.selectGoodsDefaultEvaluateById(id));
    }

    /**
     * 新增商品默认评价
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:add')")
    @Log(title = "商品默认评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsDefaultEvaluate goodsDefaultEvaluate)
    {
        return toAjax(goodsDefaultEvaluateService.insertGoodsDefaultEvaluate(goodsDefaultEvaluate));
    }

    /**
     * 修改商品默认评价
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:edit')")
    @Log(title = "商品默认评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsDefaultEvaluate goodsDefaultEvaluate)
    {
        return toAjax(goodsDefaultEvaluateService.updateGoodsDefaultEvaluate(goodsDefaultEvaluate));
    }

    /**
     * 删除商品默认评价
     */
    @PreAuthorize("@ss.hasPermi('system:evaluate:remove')")
    @Log(title = "商品默认评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(goodsDefaultEvaluateService.deleteGoodsDefaultEvaluateByIds(ids));
    }
}
